<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 王坤华
  Date: 2021/11/29
  Time: 9:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.8.2.min.js"></script>
    <script src="js/fileupload.js"></script>
    <link rel="stylesheet" href="bootstrap-4.6.0-dist/css/bootstrap.css">
    <link rel="stylesheet" href="css/img.css">
    <%--    <link rel="stylesheet" href="css.css">--%>
</head>
<body>
<form>
    <table class="table">
        <thead class="thead-dark">
        </thead>
        <tbody>
        <tr>
            <td scope="row">
                发布时间:<input type="text" name="datatime"><br>
            </td>
            <td>
                品牌:<input type="text" name="pinpainame">
                品类:<input type="text" name="pinlei"><br>
            </td>
        </tr>
        <tr>
            <td scope="row">
                产品编号:<input type="text" name="changpinbianhao"><br>
            </td>
            <td>
                主版本号:<input type="text" name="zhubanbenhao"><br>
            </td>
        </tr>
        <tr>
            <td>
                绘图文件:<input type="text" name="huituwenjian"><br>
            </td>
            <td>总用量:<input type="text" name="zongyonglian"></td>
        </tr>
        <tr>
            <td>
                从版本号:<input type="text" name="congbanbenhao"><br>
            </td>
            <td>绘图文件:<input type="text" name="huituwenjian"></td>
        </tr>
        <tr>
            <td>
                制作人:<input type="text" name="zhizuorem"><br>
            </td>
            <td>绘图文件:<input type="text" name="huituwenjian"><br></td>
        </tr>
        <tr>
            <td>
                审核人:<input type="text" name="shengheren"><br>
            </td>
            <td>备注:<input type="text" name="beizhu"><br></td>
        </tr>
        </tbody>
    </table>
    <input type="button" value="添加" onclick="add()">
</form>
<table class="table table-striped">
    <tr>
        <td>生产阶段</td>
        <td>层级</td>
        <td>物料编号</td>
        <td>物料名称</td>
        <td>型号规格</td>
        <td>单位</td>
        <td>用量</td>
        <td>位置</td>
        <td>备注</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${list1}" var="li">
        <tr>
            <td>${li.mid}</td>
            <td>${li.cengji}</td>
            <td>${li.wuliaobianhao}</td>
            <td>${li.wuliaomingcheng}</td>
            <td>${li.xinghaoguige}</td>
            <td>${li.danwei}</td>
            <td>${li.yongliang}</td>
            <td>${li.weizhi}</td>
            <td>${li.beizhu}</td>
            <td>
                <input type="button" value="删除" onclick="del(${li.mid})">
            </td>
        </tr>
    </c:forEach>
    <tr>
        <td>
            <input type="button" value="添加明细" onclick="addmi()">
        </td>
    </tr>
</body>
<script>
    function add(){
        let formData = new FormData($("form")[0]);
        $.ajax({
            url:"add.do",
            data:formData,
            type:"post",
            dataType:"json",
            processData:false,
            contentType:false,
            success:function (obj) {
                if (obj>0){
                    alert("添加成功")
                    location="list.do"
                }
            }
        })
    }
    function addmi() {
        location="addmi.do"
    }
    function del(mid) {
        $.ajax({
            url:"del.do",
            data: {"mid":mid},
            type:"post",
            dataType:"json",
            success:function (obj) {
                if (obj>0){
                    alert("删除明细记录成功")
                    location="toadd.do"
                }
            }
        })
    }
</script>
</html>
